import { Controller, Get, Post, Body } from '@nestjs/common';
import { UserId } from '../../decorators/user.decorator';
import { FamilyService } from './family.service';
import { CreateFamilyDto } from '../dto/create-family.dto';

@Controller('family')
export class FamilyController {
    constructor(private readonly familyService: FamilyService) {}

    @Get()
    getFamily(@UserId() userId: number) {
        return this.familyService.getFamily(userId);
    }

    @Post()
    async setFamily(@UserId() userId: number, @Body() createFamilyDto: CreateFamilyDto) {
        return this.familyService.setFamily(userId, createFamilyDto);
    }

    @Post('delete')
    async deleteFamily(@UserId() userId: number, @Body('id') id: number) {
        return this.familyService.deleteFamily(userId, id);
    }
}
